/** 
 * 读取配置文件
 */
package com.xuwei.utils.common;

import java.io.File;

import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.builder.fluent.Configurations;
import org.apache.commons.configuration2.ex.ConfigurationException;

/**
 * @author advance
 * 
 */
public class ConfigHelper {
	/**
	 * 读取properties配置文件
	 * @param filename
	 * @return
	 */
	public static Configuration getPropertiesFile(String filename){
		Configurations configs = new Configurations();
		try
		{
		    return configs.properties(new File(filename));
		}
		catch (ConfigurationException cex)
		{
		    // Something went wrong
		}
		return null;
	}
	
	/**
	 * 读取xml配置文件
	 * @param filename
	 * @return
	 */
	public static Configuration getXmlFile(String filename){
		Configurations configs = new Configurations();
		try
		{
		    return configs.xml(filename);
		}
		catch (ConfigurationException cex)
		{
		    // Something went wrong
		}
		return null;
	}

}
